/*
#include "wiimote_wii.h"
#if defined(_PLATFORM_WII) // all Wii titles logically use Wiimote.. :)

#include "dd/dd_man.h"
#include "font/font_manager.h"

#include "util/timer.h"				// log
#include "util/log.h"				// log
#include "util/common_macros.h"		// macros
#include "util/mmgr.h"		    

#include <revolution/wpad.h>
#include <cassert>
using namespace input;

static u32 PadChanMask[PAD_MAX_CONTROLLERS] =
{
    PAD_CHAN0_BIT, PAD_CHAN1_BIT, PAD_CHAN2_BIT, PAD_CHAN3_BIT
};


static void * CustomAlloc( unsigned long size )
{
	return MMGR_AllocEx(HEAP_MEM2, size, 4);
}
unsigned char CustomFree( void *ptr )
{
	MMGR_Free(ptr);
	return 0;
}


WiimoteWii::WiimoteWii() :
	WiimoteAbstract()
{
	WPADRegisterAllocator(CustomAlloc, CustomFree);
    WPADInit();
    memset(&m_WiimoteA[0], 0, sizeof(m_WiimoteA));	

	for (int i=0; i<PAD_MAX_CONTROLLERS; i++)
	    WPADSetDataFormat(i, WPAD_FMT_CORE_ACC);    
}

WiimoteWii::~WiimoteWii()
{

}
void	WiimoteWii::Init()
{
#ifdef VISUALIZE_WIIMOTE
	m_SampleA[SAMPLE_X].Color = ColorRGBA(255, 0, 0);
	m_SampleA[SAMPLE_Y].Color = ColorRGBA(0, 255, 0);
	m_SampleA[SAMPLE_Z].Color = ColorRGBA(0, 0, 255);
#endif//
}
void	WiimoteWii::Shutdown()
{
}

void	WiimoteWii::StartRumble(int ControllerID)
{
	if (ControllerID>=0 && ControllerID<4)
		WPADStartMotor(ControllerID);
}

void	WiimoteWii::StopRumble(int ControllerID)
{
	if (ControllerID>=0 && ControllerID<4)
		WPADStopMotor(ControllerID);
}

void	WiimoteWii::UpdatePad(int ID, WPADStatus* pPad)
{
	input::Wiimote*	pCtrl = &GET_WIIMOTE();
    if ( pPad->err != PAD_ERR_TRANSFER )
    {
        // Detects which direction is the stick(s) pointing.
        // This can be used when we want to use a stick as direction pad.
		unsigned short	Buttons = pPad->button;

 		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_UP,			Buttons & WPAD_BUTTON_UP);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_DOWN,		Buttons & WPAD_BUTTON_DOWN);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_LEFT,		Buttons & WPAD_BUTTON_LEFT);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_RIGHT,		Buttons & WPAD_BUTTON_RIGHT);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_A,			Buttons & WPAD_BUTTON_A);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_B,			Buttons & WPAD_BUTTON_B);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_Z,			Buttons & WPAD_BUTTON_Z);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_1,			Buttons & WPAD_BUTTON_1);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_2,			Buttons & WPAD_BUTTON_2);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_PLUS,		Buttons & WPAD_BUTTON_PLUS);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_MINUS,		Buttons & WPAD_BUTTON_MINUS);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_MENU,		Buttons & WPAD_BUTTON_HOME);
		pCtrl->ButtonUpdate(ID, Wiimote::BUTTON_START,		Buttons & WPAD_BUTTON_START);

	}
	pCtrl->AccelerationUpdate(ID, float(pPad->accX)/512.0f, float(pPad->accY)/512.0f, float(pPad->accZ)/512.0f);
#ifdef VISUALIZE_WIIMOTE
	// accelerometer
	m_SampleA[SAMPLE_X].AddSample(pPad->accX);
	m_SampleA[SAMPLE_Y].AddSample(pPad->accY);
	m_SampleA[SAMPLE_Z].AddSample(pPad->accZ);
#endif //VISUALIZE_WIIMOTE
}

#ifdef VISUALIZE_WIIMOTE
void	WiimoteWii::AccSamples::AddSample(short Sample)
{
	if (Sample != 0)
	{
		int j=0;
	}
	float	Time = TIMER().Time();
	if (Time > LastUpdate+SynchTime)
	{
		LastUpdate=Time;
		Values.push_back(Sample);
	}
}

void	WiimoteWii::AccSamples::Render(const math::Vec2& From, const math::Vec2& Scale, int LookBack)
{
	int	FromIdx = (int)Values.size() - LookBack;
	UTIL_CLAMP(FromIdx, 0, Values.size()-1);
	float	StepSize = Scale.x / float (LookBack);
	
	dd::Manager& DD = dd::Manager::Instance();
	math::Vec2	Prev = From;
	int		High = 0, Low = 0;
	for ( int i=FromIdx; i<(int)Values.size(); i++)
	{
		int		Sample = Values[i];
		High = UTIL_HIGH(Sample, High);
		Low = UTIL_LOW(Sample, Low);
		float	Value = Values[i] / float(MAX_SAMPLE_RANGE);
		math::Vec2 P;
		P.x = From.x + (StepSize * (i-FromIdx));
		P.y = From.y + (Scale.y * Value);
		DD.AddLine2D(Prev, P, Color);
		Prev = P;
	}
	FontManager::Instance().Print(math::Vec2(From.x + Scale.x, From.y), "%i (%i, %i)", Values[Values.size()-1], High, Low);

}


#endif //VISUALIZE_WIIMOTE

void	WiimoteWii::Tick(float dt)
{
//	WPADStartFastSimpleSync();
	
	int		Status = WPADGetStatus();
	switch (Status)
	{
		case WPAD_STATE_DISABLED:
		return;
		case WPAD_STATE_ENABLING:
		{
			for (int i=0; i<PAD_MAX_CONTROLLERS; i++)
			    WPADSetDataFormat(i, WPAD_FMT_CORE_ACC);
		}
		return;
		case WPAD_STATE_SETUP:
		case WPAD_STATE_ENABLED:
		break;
		case WPAD_STATE_DISABLING:
		return;
	}

	
	for (int i=0; i<PAD_MAX_CONTROLLERS; i++)
	{
		WPADStatus	Data;
	    WPADSetDataFormat(i, WPAD_FMT_CORE_ACC);
	    WPADRead( i, &Data);
		UpdatePad(i, &Data);
	}

#ifdef VISUALIZE_WIIMOTE
	m_SampleA[SAMPLE_X].Render(math::Vec2(0.1f, 0.1f), math::Vec2(0.7f, 0.1f), 5 / m_SampleA[SAMPLE_X].SynchTime);
	m_SampleA[SAMPLE_Y].Render(math::Vec2(0.1f, 0.2f), math::Vec2(0.7f, 0.1f), 5 / m_SampleA[SAMPLE_X].SynchTime);
	m_SampleA[SAMPLE_Z].Render(math::Vec2(0.1f, 0.3f), math::Vec2(0.7f, 0.1f), 5 / m_SampleA[SAMPLE_X].SynchTime);
#endif //VISUALIZE_WIIMOTE

}



#endif //_ENABLE_WIIMOTE_

*/
